package hust.music.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import hust.music.action.base.ActionBase;
import hust.music.service.HomePageModService;

@Controller
@Scope("session")
public class DealRelAction extends ActionBase {
	private static final long serialVersionUID = 1L;
	
	private Integer friendId;
	private String flag;
	
	@Autowired
	HomePageModService homePageModService;

	public Integer getFriendId() {
		return friendId;
	}

	public String getFlag() {
		return flag;
	}

	public void setFlag(String flag) {
		this.flag = flag;
	}

	public void setFriendId(Integer friendId) {
		this.friendId = friendId;
	}
	
	public String agreeFriendApply(){
		try {
			homePageModService.aggreeFriend(friendId);
			flag="您同意了该好友申请";
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			flag=e.getMessage();
		}
		return "agreefriend";
	}
	
	public String refuseFriendApply(){
		try {
			homePageModService.refuseFriend(friendId);
			flag="您拒绝了该好友申请";
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			flag=e.getMessage();
		}
		return "refusefriend";
	}
}
